﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SWENAssignment.HuiYi;

namespace SWENAssignment
{
    public partial class createUserAccount : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnCreate_Click(object sender, EventArgs e)
        {

            {

                string u_loginID = tbxLoginID.Text;
                userAccount u = DBmanager.GetUserAccountByLoginID(u_loginID);

                string u_UserType = ddlUserType.Text;
                string u_LoginID = tbxLoginID.Text;
                string u_Password = tbxPassword.Text;
                string u_ConfirmedPassword = tbxPassword2.Text;
                string u_LastName = tbxLastName.Text;
                string u_FirstName = tbxFirstName.Text;
                DateTime u_DateOfBirth = Convert.ToDateTime(ddlDate.SelectedValue + "/" + ddlMonth.SelectedValue + "/" + tbxYear.Text);
                int u_ContNum = Convert.ToInt32(tbxContactNo.Text);
                string u_MailAdd = tbxAddress.Text;
                string u_Email = tbxEmail.Text;
                string u_Gender = rblGender.SelectedValue;
                string u_BankAccType = ddlBankAccType.SelectedValue;
                int u_BankAccNum = Convert.ToInt32(tbxBankAccNo.Text);





                userAccount ua = new userAccount(u_UserType, u_LoginID, u_Password, u_ConfirmedPassword, u_LastName, u_FirstName, u_DateOfBirth, u_ContNum, u_MailAdd, u_Email, u_Gender, u_BankAccType, u_BankAccNum);

                if (DBmanager.InsertUserAccount(ua) == 1)
                {
                    Session["loginID"] = u_LoginID;
                    
                    Response.Redirect("createdUserAccDisplay.aspx?");
                }
                else
                {

                    lblCreateSuccessfully.Text = "Account creation unsuccessfull!";
                }

            }
        }
    }
}
